package com.we823.cms.repository.service.sys;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.google.common.collect.Maps;
import com.we823.cms.model.sys.Permission;
import com.we823.cms.repository.dao.sys.PermissionMapper;
import com.we823.cms.repository.service.AbstractBaseService;

@Service
@Scope("prototype")
public class PermissionService extends AbstractBaseService<Permission, Integer> {

	private PermissionMapper permissionMapper;
	
	@Autowired
	public PermissionService(PermissionMapper permissionMapper) {
		super(permissionMapper);
		this.permissionMapper = permissionMapper;
	}

	public Map<Integer, Permission> map() {
		Map<Integer, Permission> map = Maps.newHashMap();
		List<Permission> permissionModels = this.findAll();
		if (permissionModels!=null) {
			for (Permission permissionModel : permissionModels) {
				map.put(permissionModel.getId(), permissionModel);
			}
			return map;
		}
		return null;
	}

}
